<script setup lang="ts">
import { useRoute , useRouter } from 'vue-router'
import { onMounted, ref } from 'vue'
import Request from '@/api/axios'
import { HttpStatusCode } from 'axios'
const router = useRouter()
const route = useRoute()
const id = route.params.id
const tableData = ref(null)
onMounted(async () => {
    await Request.get({ url: `/training/${id}` })
        .then((response) => {
            if(response.code === HttpStatusCode.NotFound){
                router.push({name : 'notfound'})
                return
            }
            tableData.value = response.info
        })
        .catch(() => {})
        .finally()
})
const columns = [
    {
        title: 'ID',
        dataIndex: 'problemID',
        key: 'problemID',
        width: '11.25rem'
    },
    {
        title: '总提交数',
        dataIndex: 'submission',
        key: 'submission',
        width: '11.25rem'
    },
    {
        title: '总通过数',
        dataIndex: 'accept',
        key: 'accept',
        width: '11.25rem'
    }
]
</script>

<template>
    <a-table :dataSource="tableData" :columns="columns"  class="w-full"/>
</template>

<style scoped></style>
